<?php
$invoice = $this->invoice;
$order = $this->order;
?>
<div>
    <div class="headerinvoice">
        <a href="<?=BASE_URL?>/user/orderhistory">Invoices</a> &raquo; View invoice: #<?=$this->id?> (<?php echo $order->date_created;?>)
        <hr noshade="" size="1" color="#c0c0c0"/>
    </div>
    <?php
    
    if($order->email_content) {
        echo $order->email_content;
    } else {
    ?>
    <table width="100%">
        <tr>
            <td width="50%">
                <h2>Billing info</h2>
                <?php
                echo $order->ship_info;
                ?>

            </td>
            <td>
                <h2>Shippng info</h2>
                <?php
                echo $order->bill_info;
                ?>

            </td>
        </tr>
    </table>
    <div style="padding:10px"></div>
    <table width="100%">
        <tr style="border-bottom:1px dotted #0C0C0C">
            <th>Qty</th>
            <th>ProductNo</th>
            <th>Description</th>
            <th>Price</th>
            <th>Total</th>
        </tr>
    <?php
    if (count($invoice) > 0) {
        $sum = 0;
        foreach($invoice as $item):
        ?>
        <tr style="border-bottom:1px dotted #0C0C0C">
            <td><?=$item->Quantity?></td>
            <td><?=$item->ProductNo?></td>
            <td><?=$item->Product?></td>
            <td><?=$item->Price?></td>
            <td><?=$item->Quantity * $item->Price?></td>
        </tr>
        
        <?php
            $sum += $item->Quantity * $item->Price;
        endforeach;
    ?>

    <?php
        
    }
    ?>
    </table>
    <div style="text-align:right;padding-right:25px">
        Sub-Total: $<?=$sum?>
    </div>

<?php
}
?>
</div>